package com.glodon.cloud.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import com.glodon.cloud.domain.User;

@RestController
public class RibbonContoller {
	
	@Autowired
	private RestTemplate restTemplate  ;
	
	@GetMapping("/ribbon/sayHello/{userId}")
	public String sayHello(@PathVariable String userId){
		User user = restTemplate.getForObject("http://SERVICE-USER/user/id/"+userId, User.class); 
		return "Hello " + user.getUsername(); 
	}
}
